package com.stylefeng.guns.modular.pay.service.impl;

import com.stylefeng.guns.modular.pay.model.TransHistory;
import com.stylefeng.guns.modular.pay.dao.TransHistoryMapper;
import com.stylefeng.guns.modular.pay.dto.TransACDTO;
import com.stylefeng.guns.modular.pay.dto.TransDTO;
import com.stylefeng.guns.modular.pay.dto.TransParams;
import com.stylefeng.guns.modular.pay.service.ITransHistoryService;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 佳付通流水表 服务实现类
 * </p>
 *
 * @author stylefeng
 * @since 2018-08-17
 */
@Service
public class TransHistoryServiceImpl extends ServiceImpl<TransHistoryMapper, TransHistory> implements ITransHistoryService {
	@Autowired
	private TransHistoryMapper transHistoryMapper;
	@Override
	public List<TransHistory> list(Page<TransHistory> page, TransHistory history) {
		// TODO Auto-generated method stub
		return transHistoryMapper.list(page,history);
	}
	@Override
	public TransACDTO getExportData(TransParams param) {
		TransACDTO acdto = new TransACDTO();		
		List<TransDTO> details = transHistoryMapper.getExportData(param);
		for(TransDTO detail:details){
			if(detail.getSettleType().equals("0")){
				detail.setSettleType("D0");
			}
			if(detail.getTranStatus().equals("0")){
				detail.setTranStatus("交易成功");
			}else if(detail.getTranStatus().equals(1)){
				detail.setTranStatus("交易中");
			}else if(detail.getTranStatus().equals("2")){
				detail.setTranStatus("交易失败");
			}
		}
		acdto.setDetail(details);
		return acdto;
	}

}
